package com.cc.pojo.tablestruct;


import com.cc.pojo.bo.TransBo;
import com.cc.pojo.enums.DataBaseEnum;
import com.cc.utils.ConvertHumpUnderlinesToEachOtherUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author c.c
 * @Description 用于展示的表格结构实体类
 * @since 2022/8/11
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class TableStruct {

  //数据库名
  private String tableSchema;

  //表名
  private String tableName;

  //列名（字段名）
  private String columnName;

  //列数据类型 如:datetime varchar varchar
  private String dataType;

  //字符最大长度
  private String characterMaximumLength;

  //列类型 如：varchar(50) int(11)
  private String columnType;

  //备注信息
  private String columnComment;


  public static TransBo convertBuiderDbDtoByTableStruct(TableStruct tableStruct) {
    TransBo transBo = new TransBo();
    transBo.setRemark(tableStruct.getColumnComment());
    transBo.setReturnType(DataBaseEnum.getPropertyName(tableStruct.getDataType()));
    transBo.setDatabaseName(tableStruct.getColumnName());
    transBo.setPropertyName(ConvertHumpUnderlinesToEachOtherUtil.underlineToHump(tableStruct.getColumnName()));
    return transBo;
  }
}
